//
//  AppDelegate.swift
//  First
//
//  Created by 王友俊 on 16/1/24.
//  Copyright © 2016年 wangyj. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        
        //查询保存的cache
        //初始化appkey
        RCIM.sharedRCIM().initWithAppKey("qf3d5gbj3mugh")
        
        RCIM.sharedRCIM().connectWithToken("xN3NeuIUz2WGcyjlskyo7Xrdk8XpZ74zRO7WMQ8xL1ewgfPOfhHT7vPn8pJvMl/gSenBAi5jLXI/vzJmaMxrCg==",
            success: { (userId) -> Void in
                print("登陆成功！")
                let currentUser = RCUserInfo(userId: "one", name: "wangyj", portrait: "http://img5.duitang.com/uploads/item/201512/23/20151223045655_JkUYK.jpeg")
                RCIMClient.sharedRCIMClient().currentUserInfo = currentUser
                
            }, error: { (status) -> Void in
                print("登陆错误！")
            }, tokenIncorrect: {
                //token过期或者不正确。
                //如果设置了token有效期并且token过期，请重新请求您的服务器获取新的token
                //如果没有设置token有效期却提示token错误，请检查您客户端和服务器的appkey是否匹配，还有检查您获取token的流程。
                print("token错误")
        })
            return true
    }

    func applicationWillResignActive(application: UIApplication) {

    }

    func applicationDidEnterBackground(application: UIApplication) {
    
    }

    func applicationWillEnterForeground(application: UIApplication) {
        
    }

    func applicationDidBecomeActive(application: UIApplication) {
        
    }

    func applicationWillTerminate(application: UIApplication) {
    
    }


}

